import request from '@/utils/request'

const api = {
  goodsList: '/goods/list',
  categoryList: '/category/list',
  getMainCatList: '/category/getMainCatList',
  getCatChildrenList: '/category/getCatChildrenList',
  updateCategory: '/category/update',
  deleteCategory: '/category/delete',
  createCategory: '/category/create'
}

export default api

export function getGoodsList (parameter) {
  return request({
    url: api.goodsList,
    method: 'get',
    params: parameter
  })
}

export function getCategoryList (parameter) {
  return request({
    url: api.categoryList,
    method: 'get',
    params: parameter
  })
}

export function getMainCatList (parameter) {
  return request({
    url: api.getMainCatList,
    method: 'get',
    params: parameter
  })
}

export function getCatChildrenList (parameter) {
  return request({
    url: api.getCatChildrenList,
    method: 'get',
    params: parameter
  })
}

export function createCategory (parameter) {
  return request({
    url: api.createCategory,
    method: 'post',
    data: parameter
  })
}

export function updateCategory (parameter) {
  return request({
    url: api.updateCategory,
    method: 'post',
    data: parameter
  })
}

export function deleteCategory (parameter) {
  return request({
    url: api.deleteCategory,
    method: 'post',
    data: parameter
  })
}
